package core.genetic.crossover;

import java.util.Random;

import utility.Utils;

import core.genetic.Individual;

public class SinglePointCrossover implements Crossover{

	@Override
	public Individual crossover(Individual ind1, Individual ind2) {

		int length = ind1.getLength();
		Individual ind = new Individual(length);
		int point = Utils.random.nextInt(length);
		for (int i=0; i<length; i++){
			if (i<point){
				ind.setGene(i, ind1.getGene(i));
			}
			else ind.setGene(i, ind2.getGene(i));
		}
		return ind;

	}

}
